/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufu.sdg12014.thriftpluresdb.client;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

/**
 *
 * @author SergioPeres
 */
public class Client
{

    public final String         address;
    public static final int     port = 9090;
    public Action               action;
    private TTransport          transport = null;

    public Client(String s)
    {
        this.address = s;
        try
        {
            transport = new TSocket(address, port);
            transport.open();

            TProtocol protocol = new TBinaryProtocol(transport);

            this.action = new Action(protocol);
        } catch (TTransportException x)
        {
            x.printStackTrace();
        }
    }

    public void execute()
    {
        TextInterface.execute(action);
        this.transport.close();
    }

//    static class Client
//    {
//
//        public Client()
//        {
//        }
//    }
}
